<?php
include_once 'basepath.php';
if(isset($type))
{
	$flag=0;
	if($type=="edit")
	{
		$flag=1;
		//print_r($infouser);
	}		

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link rel="stylesheet" href="<?php echo $bpath;?>/css/reset.css" />
<link rel="stylesheet" href="<?php echo $bpath;?>/css/text.css" />
<link rel="stylesheet" href="<?php echo $bpath;?>/css/960_24_col.css" />
 <link rel="stylesheet" href="<?php echo $bpath;?>/css/jquery-ui-1.8.21.custom.css" />
 <link rel="stylesheet" href="<?php echo $bpath;?>/css/style.css" />
 <link rel="stylesheet" href="<?php echo $bpath;?>/css/faary.css" type="text/css" />
 <script type="text/javascript" src="<?php echo $bpath;?>/js/jquery-1.7.2.min.js"></script>
 <script type="text/javascript" src="<?php echo $bpath;?>/js/jquery-ui-1.8.21.custom.min.js"></script>
<script type="text/javascript" src="<?php echo $bpath;?>/js/scripts.js"></script>
 <script type="text/javascript" src="<?php echo $bpath;?>/js/jquery.validate.js"></script>
<script>
	$(function(){
		  $.validator.addMethod(
			        "regex",
			        function (value, element, regexp) {
			        	    var re = new RegExp(regexp);
			                return this.optional(element) || re.test(value);
			            },
			            "Please check your input."
			        );
$(".formtour").validate({
		submitHandler: function(form){ form.submit() },
		 onfocusout:  function(element) { $(element).valid(); },

		rules: {
			
			name: {
				required: true,
				
			},
		
			
			Email: {
     		 required: true,
   			},

   			level: {
     		 required: true,
   			},
   			
		},
		
		messages: {
			name: "Enter Tour Name (at least 8 caracter)",
			Email: "Email no complet",
			level:"Enter level"
		
			}
		
});
	});
</script>
</head>

<body>
	<script type="text/javascript">
<!--
	function isEmailValid(email){
		var e = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
		return e.test(email);
	}
	/*
	function sendForm(){
		
		
		jQuery("#imessageOK, #imessageERROR").hide();
		jQuery(".required").removeClass("required");
		if(jQuery("#TourName").val()==""){jQuery("#TourName").addClass("required");window.scroll(0,0);return false;}if(jQuery("#TourCode").val()==""){jQuery("#TourCode").addClass("required");window.scroll(0,0);return false;}if(jQuery("#Date").val()==""){jQuery("#Date").addClass("required");window.scroll(0,0);return false;}if(jQuery("#Description").val()==""){jQuery("#Description").addClass("required");window.scroll(0,0);return false;}jQuery("#SendaMessage").val("Please Wait...");		var AddDetails; AddDetails+="&TourName="+encodeURIComponent(jQuery("#TourName").val());AddDetails+="&TourCode="+encodeURIComponent(jQuery("#TourCode").val());AddDetails+="&Date="+encodeURIComponent(jQuery("#Date").val());AddDetails+="&Description="+encodeURIComponent(jQuery("#Description").val());		
		alert("Add sending function here...\n\nOr become FAARY member to download full package!")	}

*/
-->
</script>
	<div class="principal container_24">
		
		<!--logo-->
		<div class="logo grid_24">
			<div class="grid_1">&nbsp;</div>
			<div class="grid_4 logoimage"><img src="<?php echo $bpath;?>/img/logo.png" height="90"></div>
			<div class="logout grid_5"><a href="index.php?loginprocess/loginout"><img src="<?php echo $bpath;?>/img/bt_logout.jpg"/></a></div>
		</div><!-- end logo-->
		
		<!--menupricipal-->
		<div class="menuprincipal grid_24">
			<div class="menuprincipal grid_24">
			<a class="yearlist " href="index.php?liste/listuser">Back to List </a>
		</div>
		</div>
		<!-- end menupricipal-->
				
			<div class="descprincipal grid_22">
				description
				<br/>
				<h3></h3>
			</div>
			
			<div class="grid_24 listcontent">
				<?php if($flag==1){?>
				<h1>Edit User </h1>
				<?php }else{?>
				<h1>Add User </h1>
				<?php }?>
				<div class="grid_22 list">
				
<?php if($flag==1){?>
<form method="post" action="index.php?edit/actionedituser"  class="iform grid_18 formtour" onSubmit="return false">
<input type="hidden" name="idusers"  value="<?php echo $infouser[0]["idusers"]; ?>" />
<?php }else{?>
<form method="post" action="index.php?add/actionaddnewuser"  class="iform grid_18 formtour" onSubmit="return false">
<?php }?>
<div id="imessageOK">Thank you! Message Sent!</div>
<div id="imessageERROR">ERROR: Message Not Sent!</div>
<ul class="">
<?php if($flag==1){?>
<li class="iheader">Edit User </li>
<?php }else{?>
<li class="iheader">Add User </li>
<?php }?>
<li><label for="Name">*User Name</label><input class="itext" type="text" name="name" id="name" value="<?php if($flag==1) echo $infouser[0]["name"]; ?>"  /></li>
<li><label for="Password">*User Password</label><input class="itext" type="text" name="pwd" id="pwd" value="<?php if($flag==1) echo $infouser[0]["pwd"]; ?>" /></li>
<li><label for="Email">*User Email</label><input class="itext" type="text" name="email" id="email"  value="<?php if($flag==1) echo $infouser[0]["email"]; ?>" /></li>
<li><label for="level">*Level</label><select class="iselect" name="level" id="level">

<option value="sales" <?php if($flag==1){if($infouser[0]["level"]=="sales"){?>selected<?php }} ?>>Sales</option>
<option value="admin"  <?php if($flag==1){ if($infouser[0]["level"]=="admin"){?>selected<?php }} ?>>Admin</option>
</select>
</li>
<li><input type="submit" value="Submit" /></li>
</ul>


</form>
				</div>
			</div>
		
	</div><!--end principal-->
</body>
</html>
<?php }?>